Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use daggy's StableDag #147

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Use daggy's StableDag #147

wants to merge 3 commits into from

Conversation

fwcd
Copy link
Contributor

@fwcd fwcd commented Sep 14, 2019

Using StableDag should fix the index-shifting behavior, which previously occurred when nodes were removed from the graph.

There are a few API-breaking changes with this solution, however:

  • raw_nodes is replaced by node_references
  • raw_edges is replaced by edge_references
  • Walker's next_node and next_edge are replaced by walk_next (as defined by the upstream API)

Fix RustAudio#103.

Use the StableDag structure which (which uses petgraph's StableGraph)
implements a directed acyclic graph with stable indices.
Use the new Walker API.
for connection in self.dag.edge_weights_mut() {
let edge_ids = self.edge_references().map(|e| e.id()).collect::<Vec<_>>();
for edge_id in edge_ids {
let connection = self.connection_mut(edge_id).unwrap();
Copy link
Contributor Author

@fwcd fwcd Sep 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this also means that we cannot mutably iterate the graph's nodes/edges directly (yet). To address this, I have implemented this workaround which is slightly less efficient.

@@ -19,7 +19,7 @@ name = "dsp"
path = "./src/lib.rs"

[dependencies]
daggy = "0.4.0"
daggy = { git = "https://github.com/mitchmindtree/daggy", rev = "bcb36c7b", features = ["stable_dag"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we might want to update to the next proper version of daggy once it is released to crates.io.

The EdgeRef trait provides information about the edges returned by
Graph::edge_references.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant